<?php
/*
 * 外包网站联系我们接口
 */

namespace App\Http\Controllers\App\V1;

use Carbon\Carbon;
use App\Response\Response;
use Illuminate\Http\Request;
use App\Exceptions\BasicException;
use App\Http\Controllers\BaseController;

class ContactController extends BaseController
{

    public function contactUs(Request $request)
    {
        $name = $request->input('name');
        $phone = $request->input('phone');
        $job = $request->input('job', '');
        $intro = $request->input('intro', '');
        if (!$name) {
            throw new BasicException(0, '请输入姓名');
        }
        if (!$phone) {
            throw new BasicException(0, '请输入电话');
        }
        app('model_contact')->insert([
            'name'     => $name,
            'phone'    => $phone,
            'job'      => $job,
            'intro'    => $intro,
            'add_time' => Carbon::now()->timestamp,
        ]);

        return Response::sendData(1);
    }
}
